#!/usr/bin/env ruby

error_count = 0
warning_count = 0
note_count = 0

LKP_SRC = ENV['LKP_SRC'] || File.direname(File.dirname(File.realpath($PROGRAM_NAME)))
require "#{LKP_SRC}/lib/common"

if ENV['RESULT_ROOT']
    fn = File.join ENV['RESULT_ROOT'], 'output'
elsif ARGV[0]
    fn = ARGV[0]
end

contents = File.read(fn).split("\n")
contents.each do |line|
  case line
  when /^.*\.(c|cpp|cc|cxx|C|h|m):\d+:\d+: error: .+$/
    error_count += 1
    puts "eid." + build_pkg_error_id(line) + ": 001"
  when /^.*\.(c|cpp|cc|cxx|C|h|m):\d+:\d+: warning: .+$/
    warning_count += 1
    puts "eid." + build_pkg_error_id(line) + ": 001"
  when /^.*\.(c|cpp|cc|cxx|C|h|m):\d+:\d+: note: .+$/
    note_count += 1
    puts "tcase." + build_pkg_error_id(line) + ": 001"
  end
end

puts ".result.error: #{error_count}"
puts ".result.warning: #{warning_count}"
puts ".result.note: #{note_count}"

puts "ttotal.nr_error: #{error_count}"
puts "ttotal.nr_warning: #{warning_count}"
puts "ttotal.nr_note: #{note_count}"
